package com.ktjy.factory;

import com.ktjy.dao.PetDao;
import com.ktjy.dao.impl.PetDaoMySQLImpl;
import com.ktjy.dao.impl.PetDaoOracleImpl;

/**
 * @return 13141
 * 2025/6/19
 * 08:54
 */
public class PetDaoFactory {
    // 此默认名称可以通过读取 properties配置文件进行修改
    public static String defaultBeanName = "petDaoMySQLImpl";

    /**
     * 负责根据名称获取对应的 PetDao 实现对象
     * @param beanName
     * @return
     */
    public static PetDao getInstance(String beanName) {
        PetDao petDao = null;
        switch (beanName) {
            case "petDaoMySQLImpl":
                petDao = new PetDaoMySQLImpl();
                break;
            case "petDaoOracleImpl":
                petDao = new PetDaoOracleImpl();
                break;
            default:
                throw new RuntimeException("未找到 " + beanName + " 对应的对象");
        }
        return petDao;
    }
}
